{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}

{% block toolbar %}
  {% set icon %}
    <img width="20" height="28" alt="Database" src="" />
    <span class="sf-toolbar-status{% if 50 < collector.querycount %} sf-toolbar-status-yellow{% endif %}">{{ collector.querycount }}</span>
  {% endset %}
  {% set text %}
    <div class="sf-toolbar-info-piece">
      <b>Database Queries</b>
      <span>{{ collector.querycount }}</span>
    </div>
  {% endset %}
  {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
{% endblock %}

{% block menu %}
  <span class="label">
        <span class="icon"><img src="" alt="" /></span>
        <strong>SpoonDatabase</strong>
        <span class="count">
            <span>{{ collector.querycount }}</span>
        </span>
    </span>
{% endblock %}

{% block panel %}
  <h2>Queries</h2>

  {% if collector.queries is empty %}
    <p>
      <em>No queries.</em>
    </p>
  {% else %}
    <table class="alt">
      <tbody>
        {% for i, query in collector.queries %}
          <tr class="">
          <{{ cycle(['th', 'td'], i) }}>
          {{ query.query_formatted | raw }}<br />
          <small>
            <strong>Parameters:</strong>
            [
            {% for parameter in query.parameters %}
              {{ parameter }}{% if not loop.last %},{% endif %}
            {% endfor %}
            ]
          </small>
          </{{ cycle(['th', 'td'], i) }}>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endif %}

  <style>
    th small {
      font-weight: normal;
    }

    th pre {
      background: none !important;
      font-weight: normal;
    }
  </style>
{% endblock %}
